package com.youngwang.threadPool;

/**
 * 线程执行类
 *
 * @author youngwang
 *         Date: 2016/8/31
 */
public class WorkerThread implements Runnable {

    private String command;

    public WorkerThread(String command) {
        this.command = command;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "-Start. Command:" + command);
        processCommand();
        System.out.println(Thread.currentThread().getName() + "-End.");
    }

    private void processCommand() {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return this.command;
    }
}
